home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / comm / dup40.zip / DUP.PRG < prev    next >
Text File  |  1992-03-10  |  4KB  |  141 lines

  1. * DUP.PRG written by Michael MacDonald 09/09/90 Modified 03/10/92
  2. *
  3. SET TALK OFF
  4. SET CURSOR OFF
  5. bbs="********"
  6. mtag="**"
  7. tagyn="N"
  8. PARAMETERS mtag, bbs
  9. IF ISCOLOR()
  10.    SET COLOR TO W/B
  11. ENDIF
  12. CLEAR
  13. @ 1,20 SAY  "DUP v4.0 by Michael MacDonald (c)1990-92"
  14. @ 2,5 SAY "A program to delete duplicate filenames from ROBOCOMM's new files list"
  15. p=0
  16. num=0
  17. count=0
  18. d=0
  19. n=0
  20. crlf=CHR(13) + CHR(10)
  21. line1="                           FILES MARKED AS DELETED"+crlf
  22. line2="├─────────── DUPS ────────────────┤ "+DTOC(DATE())+" ├────────────── DUPS ─────────────┤"+crlf
  23. @ 4,5 SAY "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"
  24. DO CASE
  25. CASE FILE("new30.dbf")
  26.    USE new30 INDEX files
  27.    @ 6,5 SAY "Using NEW30.DBF"
  28. CASE FILE("new40.dbf")
  29.    USE new40 INDEX files
  30.    @ 6,5 SAY "Using NEW40.DBF"
  31. OTHERWISE
  32.    @ 6,5 SAY "Can't find NEWxx.DBF"
  33.    ?
  34.    SET CURSOR ON
  35.    QUIT
  36. ENDCASE
  37. msize=RECCOUNT()
  38. @ 7,5 SAY "Sorting on index FILES.NTX"
  39. @ 8,5 SAY "Looking for duplicates"
  40. IF UPPER(SUBSTR(mtag,1,2))="/T"
  41.    tagyn="Y"
  42.    bbs=UPPER(RTRIM(bbs))
  43. ELSE
  44.    bbs=UPPER(RTRIM(mtag))
  45. ENDIF
  46. IF SUBSTR(bbs,1,2)<>"**"
  47.    @ 9,5 SAY "Saving files from "
  48.    ?? bbs
  49. ELSE
  50.    @ 9,5 SAY "No BBS preference"
  51. ENDIF
  52. DO WHILE .NOT. EOF()
  53.    num=num+1
  54.    line=INT((num/msize)*70)
  55.    IF line>0
  56.       @ 4,4+line SAY "█"
  57.    ENDIF
  58.    IF msize < 70 .AND. line < 70
  59.       @ 4,5+line SAY "█"
  60.    ENDIF
  61.    mfile=file_name
  62.    IF PCOUNT()=0 .OR. PCOUNT()=1 .AND. tagyn="Y"
  63.       bbs=RTRIM(id)
  64.    ENDIF
  65.    SKIP
  66.    IF file_name=mfile
  67.       SKIP -1
  68.       num=num-1
  69.       DO WHILE file_name=mfile
  70.          num=num+1
  71.          n=n+1
  72.          line=INT((num/msize)*70)
  73.          IF line>0
  74.             @ 4,4+line SAY "█"
  75.          ENDIF
  76.          IF RTRIM(id)<>RTRIM(bbs) .AND. ! DELETED()
  77.             @ 10,5 SAY "Deleting -->"
  78.             @ 10,18 SAY mfile
  79.             buffer = mfile +"  "+ file_date+"  "+id+" "+ SUBS(DESC,1,45)
  80.             DELETE
  81.             d=d+1
  82.             count=count+1
  83.             p=1
  84.             IF tagyn="Y"
  85.                REPLACE TAG WITH .T.
  86.             ENDIF
  87.             IF count<2
  88.                IF ! FILE("DELETED.FIL")
  89.                   handle = FCREATE("DELETED.FIL")
  90.                   FWRITE(handle,crlf)
  91.                   FWRITE(handle,line1)
  92.                   FWRITE(handle,crlf)
  93.                   FWRITE(handle,line2)
  94.                   FWRITE(handle,crlf)
  95.                ELSE
  96.                   handle = FOPEN("DELETED.FIL",2)
  97.                   FSEEK(handle,0,2)
  98.                   FWRITE(handle,crlf)
  99.                   FWRITE(handle,line2)
  100.                   FWRITE(handle,crlf)
  101.                ENDIF
  102.             ENDIF
  103.             FWRITE(handle,buffer)
  104.             FWRITE(handle,crlf)
  105.          ENDIF
  106.          SKIP
  107.       ENDDO
  108.       IF d>0 .AND. d=n
  109.         SKIP -1
  110.         RECALL
  111.         IF tagyn="Y"
  112.            REPLACE TAG WITH .F.
  113.         ENDIF
  114.         SKIP
  115.         d=0
  116.         n=0
  117.       ENDIF
  118.    ENDIF
  119. ENDDO
  120. IF count>0 .AND. tagyn="Y"
  121.    @ 10+p,5 SAY "Tagging "+LTRIM(STR(count))+" duplicate files"
  122.    INDEX ON IF(TAG,"Y",fstatus)+SUBS(file_name,1,3) TO ntag
  123.    FCLOSE(handle)
  124.    ? "     All done!"
  125. ENDIF
  126. IF count>0 .AND. tagyn<> "Y"
  127.    @ 10+p,5 SAY LTRIM(STR(count))+" duplicate files deleted"
  128.    FCLOSE(handle)
  129.    ? "     All done!"
  130. ENDIF
  131. IF count=0
  132.    @ 10+p,5 SAY "No duplicate files found"
  133.    ? "     All done!"
  134. ENDIF
  135. ?
  136. SET CURSOR ON
  137. CLOSE ALL
  138. QUIT
  139. *
  140. * EOF DUP.PRG
  141.